<?php

include '../../../configuration.php';

$category_id = $_POST['category'];
$complexity = $_POST['complexity'];
$m_q_id = $_POST['question_id'];
$question= $_POST['question'];
$choices = $_POST['choice'];
$choice_id = $_POST['answers'];
$answer = $_POST['radio'];

echo "UPDATE `questions` SET `q_title`='$question', `cat_id`='$category_id', `q_complexity`='$complexity', `q_udate`=now() WHERE q_id = $m_q_id";

mysql_query("UPDATE `questions` SET q_title='$question', cat_id='$category_id', q_complexity='$complexity', q_udate=now() WHERE q_id = $m_q_id");

$hold_answer = 0;

for ($j = 0; $j < 4; $j++) {
	if ($j == $answer) $hold_answer = 1;
	echo "<br>".$j." ".$hold_answer;
	
	mysql_query("UPDATE `choices` SET `c_title` = '$choices[$j]', `c_order` = $j+1, `c_correctvalue` = '$hold_answer', `udate` = now() WHERE `q_id` = $m_q_id AND c_id = $choice_id[$j]");

	$hold_answer = 0;
}
header("Location: modifing_question.php");
?>
